package com.youjiang.springboot.handle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.youjiang.springboot.filter.TestFilter;
import com.youjiang.springboot.utils.JsonFormatUtils;

/**
 * Description: 异常处理
 * Company: youjiang
 * @author Kwum
 * @date 2017年4月22日 下午4:02:40
 * @version 1.0
 */
@ControllerAdvice
public class ExceptionHandle {
	
	//创建日志对象
	private final static Logger log=LoggerFactory.getLogger(TestFilter.class);

	@ExceptionHandler(value = Exception.class)
	@ResponseBody
	public String exceptionHandle(Exception exception){
		
		log.error("系统异常", exception);
		return JsonFormatUtils.formatReturn(-1, exception.toString()).toString();
	}
}
